<?php 
ob_start();
session_start();
$teamid=$_SESSION['teamID'];
if ($_SESSION['teamID']!=1){header('LOCATION:main.php');}
?>
<!DOCTYPE html>
<html>
<head>
<title>Coach</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="Content/site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/bootstrap-datepicker.js"></script>
</head>
<body>
<?php include_once("php/coach_classes.php");?>
<div class="container blue_border">
<?php 
include_once("php/banner.php");
?>
  <?php 
include_once("php/nav_bar.php");
?>
  <h1>Assign Fill-in</h1>
  <div class="panel-group" id="accordion">
    <?php 
	foreach($allRounds as $r){
?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <div class="row"> <a data-toggle="collapse" data-parent="#accordion" href="#round<?php echo $r->roundID;?>">
          <div class="col-md-2 col-xs-5"><h4 class="panel-title"> <?php echo "Round ".$r->round_number;?></h4></div>
          <div class="col-md-2 col-xs-7">
            <h4 class="panel-title"> <?php echo $r->round_date;?> </h4>
          </div>
          </a> </div>
        <div id="round<?php echo $r->roundID;?>" class="panel-collapse collapse">
          <div class="panel-body">
            <?php
		  $schedles=$repSchedule->maps($repSchedule->getScheduleByRoundID($r->roundID));
		  foreach($schedles as $s){ 
		  include("php/main_teams_open.php");
		  ?>
            <div class="container-fluid">
              <div class="row">
                <h5><?php echo $team1->team_name;?></h5>
              </div>
              <div class="row">
                <form action="php/update_players_t1.php" role="form" method="post" class="form">
                  <input type="hidden" name="scaduleId" id="scaduleId" value="<?php echo  $s->round_scheduleID; ?>" />
                  <?php $players1=$repTeam->getPlayers1ByRoundScheduleID($s->round_scheduleID);
				$players2=$repTeam->getPlayers2ByRoundScheduleID($s->round_scheduleID); ?>
                  <?php $player=$repPlayer->map($repPlayer->readPlayer($players1[0])); ?>
                  <div class="col-md-3">
                    <input type="hidden" name="player1T1_old" id="player1T1_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player1T1" id="player1T1">
                      <option value="<?php echo $player->playerID; ?>"> <?php echo $player->fname." ".$player->sname; ?></option>
                      <?php $players=$repPlayer->maps($repPlayer->getAvailablePlayers($schedle->roundID));
									foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <?php $player=$repPlayer->map($repPlayer->readPlayer($players1[1])); ?>
                    <input type="hidden" name="player2T1_old" id="player2T1_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player2T1" id="player2T1">
                      <option value="<?php echo $player->playerID; ?>"> <?php echo $player->fname." ".$player->sname; ?></option>
                      <?php $players=$repPlayer->maps($repPlayer->getAvailablePlayers($schedle->roundID));
						foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <?php $player=$repPlayer->map($repPlayer->readPlayer($players1[2])); ?>
                    <input type="hidden" name="player3T1_old" id="player3T1_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player3T1" id="player3T1">
                      <option value="<?php echo $player->playerID; ?>"> <?php echo $player->fname." ".$player->sname; ?></option>
                      <?php $players=$repPlayer->maps($repPlayer->getAvailablePlayers($schedle->roundID));
							foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <button class="btn btn-default btn-sm" type="submit" name="submit">Assign</button>
                  </div>
                </form>
              </div>
              <div class="row">
                <h5><?php echo $team2->team_name;?></h5>
                <form action="php/update_players_t2.php" role="form" method="post" class="form">
                  <div class="col-md-3">
                    <?php $player=$repPlayer->map($repPlayer->readPlayer($players2[0]));?>
                    <input type="hidden" name="player1T2_old" id="player1T2_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player1T2" id="player1T2">
                      <option  value="<?php echo $player->playerID; ?>"><?php echo $player->fname." ".$player->sname; ?></option>
                      <?php foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <?php $player=$repPlayer->map($repPlayer->readPlayer($players2[1]));?>
                    <input type="hidden" name="player2T2_old" id="player2T2_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player2T2" id="player2T2">
                      <option  value="<?php echo $player->playerID; ?>"><?php echo $player->fname." ".$player->sname; ?></option>
                      <?php foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <?php $player=$repPlayer->map($repPlayer->readPlayer($players2[2]));?>
                    <input type="hidden" name="player3T2_old" id="player3T2_old" value="<?php echo $player->playerID; ?>" />
                    <select class="form-control" name="player3T2" id="player3T2">
                      <option  value="<?php echo $player->playerID; ?>"><?php echo $player->fname." ".$player->sname; ?></option>
                      <?php foreach ($players as $p){?>
                      <option value="<?php echo $p->playerID; ?>"><?php echo ($p->fname." ".$p->sname); ?></option>
                      <?php } ?>
                    </select>
                  </div>
                  <div class="col-md-3">
                    <button class="btn btn-default btn-sm" type="submit" name="submit">Assign</button>
                  </div>
                </form>
              </div>
            </div>
            <?php }?>
          </div>
        </div>
      </div>
    </div>
    <?php	} ?>
  </div>
</div>
<?php ob_flush();?>
</body>
</html>
